package mysql

import "fmt"

type Conf struct {
	Host         string
	Port         int
	User         string
	Password     string
	DBName       string
	TablePrefix  string `json:",optional"`
	Debug        bool
	Parameters   string `json:",optional"`
	MaxLifetime  int    `json:",optional"`
	MaxOpenConns int    `json:",optional"`
	MaxIdleConns int    `json:",optional"`

	ReadTimeout  int `json:",optional"`
	WriteTimeout int `json:",optional"`
}

func (a Conf) DSN() string {
	return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?%s",
		a.User, a.Password, a.Host, a.Port, a.DBName, a.Parameters)
}
